package com.itheima.d1_date;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Demo4 {
    public static void main(String[] args) {


        LocalDate now = LocalDate.now();
        LocalTime now1 = LocalTime.now();
        LocalDateTime now2 = LocalDateTime.now();

        System.out.println(now);
        System.out.println(now1);
        System.out.println(now2);

        System.out.println("-----------------");

        LocalDate of = LocalDate.of(2099, 12, 30);
        LocalTime of1 = LocalTime.of(12, 12, 11);
        LocalDateTime of2 = LocalDateTime.of(of, of1);

        System.out.println(of);
        System.out.println(of1);
        System.out.println(of2);



        System.out.println(now2.getYear());
        System.out.println(now2.getMonth());
        System.out.println(now2.getDayOfMonth());
        System.out.println(now2.getHour());
        System.out.println(now2.getMinute());
        System.out.println(now2.getSecond());


        LocalDateTime localDateTime = now2.withYear(2099).withMonth(6);
        System.out.println(localDateTime);

        LocalDateTime localDateTime1 = now2.plusYears(1).plusMonths(1).plusDays(1);
        System.out.println(localDateTime1);

        LocalDateTime localDateTime2 = now2.minusHours(1).minusMinutes(1).minusSeconds(1);
        System.out.println(localDateTime2);

        System.out.println("--------------");
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        LocalDateTime now3 = LocalDateTime.now();
        System.out.println(now3);

        String format = dateTimeFormatter.format(now3);
        System.out.println(format);

        LocalDateTime parse = LocalDateTime.parse("2023-07-03 12:12:12", dateTimeFormatter);
        System.out.println(parse);

        System.out.println("-------------");
        System.out.println("Math.max(10,8) = " + Math.max(10, 8));
        System.out.println("Math.min(10,2) = " + Math.min(10, 2));

        System.out.println("Math.floor(-13.4) = " + Math.round(-13.6));

    }
}
